/**
 * Label与Hidden结合的Field
 * @class Ext.form.LabelField
 * @extends Ext.BoxComponent
 * @author Wuqingming
 */
Ext.form.LabelField = Ext.extend(Ext.BoxComponent,  {
	isFormField : true,
 	//inputType : 'text',
 	originalValue: '',
 	labelRenderer: null,
	onRender : function(ct, position){
		 try {
	    	if(!this.el){
	            this.el = document.createElement('span');
	            this.el.id = (this.id || this.name) + "_text";
	            this.el.style.margin = "3 2 0 0px";
	        }
	        if(!this.el2){
	        	var el2Name = this.name || this.id;
	        	var el2Id = this.id || this.name;
	            this.el2 = ct.createChild({tag: 'input', type: 'hidden', name: el2Name, id: el2Id}, position);
	        }
		} catch (e) {}
        Ext.form.LabelField.superclass.onRender.call(this, ct, position);
        this.setValue(this.value);
    },
    setValue : function (v) {
    	this.value = v;
        if(this.rendered){
            this.el2.dom.value = (v === null || v === undefined ? '' : v);
        }
        if (this.labelRenderer != null && typeof this.labelRenderer == 'function') {
        	this.labelRenderer(v,  this.id || this.name);
        }
    },
    getValue : function(){
        if(!this.rendered) {
            return this.value;
        }
        var v = this.el2.getValue();
        if(v === this.emptyText || v === undefined){
            v = '';
        }
        return v;
    },
    reset : function(){
        this.setValue(this.originalValue);
        //this.clearInvalid();
    },
    validate : function () {
    	return true;
    }
});
Ext.reg('labelfield', Ext.form.LabelField);